package com.fosu.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * 用户类
 *
 * @author manno
 * @date 2020/10/9
 */
@Data
@Component
public class User {
    /**
     * 用户ID
     */
    private int userId;
    /**
     * 手机号
     */
    private String phone;
    /**
     * 微信号
     */
    private String wechatId;
    /**
     * 真实姓名
     */
    private String realName;
    /**
     * 用户名
     */
    private String nickName;
    /**
     * 头像图片url
     */
    private String avatarUrl;
    /**
     * 微信openId
     */
    @JsonIgnore
    private String openId;
    /**
     * 登录时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date loginTime;
    /**
     * 上一次登录时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastLoginTime;

    /**
     * 用户校区
     */
    private Campus userCampus;

    public Date getLoginTime() {
        return loginTime;
    }

    public Date getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLoginTime(Date loginTime) {
        this.loginTime = loginTime;
    }


    public void setLastLoginTime(Date lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }

    /**
     * 性别
     */
    private String genderStr;
    private Integer gender;

    private String city; //wx中设置的城市
    private String province; //wx中设置的省份
    private String country;//wx中设置的国家


    public String getGenderStr() {
        if (gender == null) {
            gender = 0;
        }
        if (gender == 1) {
            genderStr = "男";
        } else if (gender == 2) {
            genderStr = "女";
        } else if (gender == 0) {
            genderStr = "未知";
        }
        return genderStr;
    }

    public String getWechatId() {

        return wechatId;
    }

    public void setWechatId(String wechatId) {
        this.wechatId = wechatId;
    }
}
